import Vue from 'vue'
//js-cookie操作cookie
import Cookies from 'js-cookie'
//重置样式
import 'normalize.css/normalize.css' // a modern alternative to CSS resets
//引入element-ui
import Element from 'element-ui'
import './styles/element-variables.scss'
//自己的样式
import '@/styles/index.scss' // global css
//APP
import App from './App'
//仓库
import store from './store'
//路由
import router from './router'
//国际化
import i18n from './lang' // internationalization
//图表
import './icons' // icon
//权限
import './permission' // permission control

import './utils/error-log' // error log
//过滤器
import * as filters from './filters' // global filters

// 编辑器
import VueMarkdownEditor from '@kangc/v-md-editor';
import '@kangc/v-md-editor/lib/style/base-editor.css';
import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js';
import '@kangc/v-md-editor/lib/theme/style/vuepress.css';
import Prism from 'prismjs';
import createLineNumbertPlugin from '@kangc/v-md-editor/lib/plugins/line-number/index';
import createTipPlugin from '@kangc/v-md-editor/lib/plugins/tip/index';
import createEmojiPlugin from '@kangc/v-md-editor/lib/plugins/emoji/index';
import createTodoListPlugin from '@kangc/v-md-editor/lib/plugins/todo-list/index';
import createCopyCodePlugin from '@kangc/v-md-editor/lib/plugins/copy-code/index';
import createAlignPlugin from '@kangc/v-md-editor/lib/plugins/align';
import '@kangc/v-md-editor/lib/plugins/copy-code/copy-code.css';
import '@kangc/v-md-editor/lib/plugins/todo-list/todo-list.css';
import '@kangc/v-md-editor/lib/plugins/emoji/emoji.css';
import '@kangc/v-md-editor/lib/style/preview-html.css';
VueMarkdownEditor.use(vuepressTheme, {
  Prism,
  config: {
    toc: {
      includeLevel: [1, 2, 3, 4, 5],
    },
  },

}).use(createLineNumbertPlugin()).use(createTipPlugin()).use(createEmojiPlugin()).use(createTodoListPlugin()).use(createCopyCodePlugin())
.use(createAlignPlugin());
Vue.use(VueMarkdownEditor);


//自定义全局组件
import RightToolBar from '@/components/RightToolBar'
Vue.component('RightToolBar', RightToolBar)
import Pagination from '@/components/Pagination'
Vue.component('Pagination', Pagination)

//echarts
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

//生产环境 npm run dev时候 node_env就是development
if (process.env.NODE_ENV === 'production') {
  //mockXHR()会拦截ajax请求，返回mock数据
  const { mockXHR } = require('../mock')
  mockXHR()
}
//使用element-ui
Vue.use(Element, {
  //设置组件默认大小：不设置默认meduim
  size: Cookies.get('size') || 'medium', // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
})

// 注册全局过滤器
Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})
//关闭生产环境vue提示
Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
    beforeCreate(){
    Vue.prototype.$bus = this
  },
  store,
  i18n,
  render: h => h(App)
})
